Release 10.1A: OpenEdge Development:
Progress 4GL Reference
SUBSTRING statement
Replaces characters in a field or variable with an expression you specify.
Syntax
sourceA field or variable of type CHARACTER or LONGCHAR in which you want to store the specified
expression.positionAn integer expression that indicates the position in
sourcein which you want to start storingexpression. Ifpositionis longer thansource, Progress padssourcewith blanks to equal the length ofposition.lengthAn integer expression that indicates the number of positions you want to replace in
source. If you specify a length of 0, the expression is inserted at thepositionand everything else moves to the right. If you do not use thelengthargument or specify -1 as the length, SUBSTRING puts the entireexpressionintosource, replacing everything insourcenecessary to make room forexpression.typeA character expression that directs Progress to interpret the specified
positionandlengthvalues as character units, bytes, or columns. A double-byte character registers as one character unit. By default, Progress interprets the specifiedpositionandlengthvalues as character units.There are three valid types: "CHARACTER," "RAW,".and "COLUMN." The expression "CHARACTER" specifies character units. The expression "RAW" specifies bytes. The expression "COLUMN" specifies display or print character-columns. If you specify the type as a constant expression, Progress validates the type specification at compile time. If you specify the type as a non-constant expression, Progress validates the type specification at run time.
Note: Ifsourceis a LONGCHAR expression, "CHARACTER" is the only valid type and the default type.expressionA constant, field name, variable name, or expression of type CHARACTER or LONGCHAR that results in a character string whose value you want to store in
Examplesource. Progress does not pad or truncateexpression.The
r-sub.pprocedure uses the SUBSTRING statement to replace a segment of text with the expression in the SUBSTRING statement XXXXXXXXX. The procedure first displays the text you can work with in the Original Text frame. Then the procedure prompts you for the start position of the replacement and the length of the replacement. Under the WORD heading, you see the revised text.
Notes
- When you use the SUBSTRING statement, the length of the target string may change (because the length of the expression value is not the same as the length of the substring you are replacing). By contrast, the OVERLAY statement never changes the length of the target string. The OVERLAY statement truncates or pads the expression value to make it the same length as the substring to be replaced.
- Do not split double-byte characters. This statement allows you to replace either the lead- or trail-byte of the target string when you specify "RAW" for the
typeparameter.See also
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |